import { AfterRecover, AfterSoftRemove, Column } from 'typeorm'

// 支持软删除的实体类
export abstract class SoftDeleteEntity {
  // 是否删除
  @Column('boolean', { comment: '是否删除', default: false, select: false })
  is_deleted: boolean

  // 软删除后的回调
  @AfterSoftRemove()
  afterSoftRemove() {
    this.is_deleted = true
  }

  // 恢复后的回调
  @AfterRecover()
  afterRecover() {
    this.is_deleted = false
  }
}
